<template>
    <div>
        <aplid-base-crud ref="crud" class="w-100" v-bind="theConfig" :paramsObj="params">
            <template v-slot:DetailDialog="{ row, show }">
                <Archives
                @refresh="handleRefresh"
                @operate="handleOperate"
                :key="show"
                :api="theConfig.api"
                :nowRowData="row"
                >
                </Archives>
            </template>
        </aplid-base-crud>
    </div>
</template>

<script setup lang="ts">

import { baseConfig } from './config'
// import RosterPart from './Roster/index.vue'
import Archives from './Archives/index.vue'
import { editConfig } from '@/views/datacenter/comprehensiveQueries/utils/index'

type Props = {
  ifShowSearch?:any
  isWithAuth?:any
  isComprehensiveQueries?: boolean
}
const props = withDefaults(defineProps<Props>(), {
  ifShowSearch:true,
  isWithAuth:undefined,
  isComprehensiveQueries: false
})
let params = reactive({
  code: 3009,
  isWithAuth:props.isWithAuth
})

let theConfig: any = ref({})

if (baseConfig) {
	let defaultConfig = JSON.parse(JSON.stringify(baseConfig))
	if (props.isComprehensiveQueries) {
		theConfig.value = editConfig(defaultConfig)
	} else {
		if (props.ifShowSearch) {
			theConfig.value = baseConfig
		} else {
			defaultConfig.searchConfig = undefined
			defaultConfig.auth.import = undefined
			defaultConfig.auth.mulitSet = undefined
			theConfig.value = defaultConfig
		}
	}
}

const crud = ref()
const dialogVisible = ref(false)
const handleRefresh = (query, visible = false) => {
  console.log('请求',query)
  dialogVisible.value = visible
  nextTick(() => {
    crud.value.refreshChange(query)
  })
}
const handleOperate = (type, row, title) => {
  nextTick(() => {
    crud.value.handleOperate(type, row, title)
  })
}
</script>
<style scoped lang="scss"></style>